<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="新增贷款信息表" bodyClass="white-bg" libs=["prism","bootstrapSelect","ueditor"]/>
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-loan-add"  class="form-horizontal">
    <input  type="hidden" name="userId" value="${user.id}">
    <input  type="hidden" name="userName" value="${user.name}">
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "销售员"/>：
    </label>
        <div class="col-sm-8"><input name="saleUserid" class="form-control" type="text" value="${user.name}" readonly="true">
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "销售员"/>：
    </label>
        <div class="col-sm-8"><input name="saleUserid" class="form-control" type="text" readonly="true">
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "销售订单编号"/>：
    </label>
        <div class="col-sm-8"><input name="saleOrderNumber" class="form-control" type="text" readonly="true">
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "车辆识别号"/>：
    </label>
        <div class="col-sm-8"><input name="outCarVin" class="form-control" type="text" readonly="true">
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><@ctx.i18n text = "车型"/>：
    </label>
        <div class="col-sm-8"><input name="outCarVehicle" class="form-control" type="text" readonly="true">
        </div>
    </div>
    <div class="form-group">        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "申请贷款金额"/>：
    </label>
        <div class="col-sm-8"><input name="loanApplyMoney" class="form-control" type="text"  required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "申请备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="loanApplyMemo" class="form-control" required></textarea>
        </div>
    </div>

</@form.form>
</div>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "bpm/loan"
    $("#form-loan-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        var newString =$('#form-loan-add').serialize()+ "&delFlag=0";
        /*
        var intervalDay='';
        var orderTakeEffectTime=$("[name='orderTakeEffectTime']").val();
        var collectionTime=$("[name='collectionTime']").val();
        if(!isNullOrEmpty(orderTakeEffectTime)&&!isNullOrEmpty(collectionTime)){
            var timeSpan=new Date(collectionTime)-new Date(orderTakeEffectTime);
            intervalDay=Math.floor(timeSpan/(24*3600*1000)).toString();
        }
        var interestRate=$("[name='interestRate']").val();
        console.log("利息率",interestRate)
        var loanMoney=$("[name='loanMoney']").val();
        console.log("贷款金额",loanMoney)
        var costOfCapital=parseFloat(loanMoney)*parseInt(intervalDay)*parseFloat(interestRate);
        console.log("资金成本",costOfCapital.toFixed(4))
        console.log("赋值前对象的值为",newString)
        if(newString.includes("intervalDay")){
            newString=newString.replace("&intervalDay=",("&intervalDay="+intervalDay));
        }
        else{
            newString=newString+ "&intervalDay="+intervalDay;
        }
        if(newString.includes("costOfCapital")){
            newString=newString.replace("&costOfCapital=",("&costOfCapital="+costOfCapital.toFixed(4)));
        }
        else{
            newString=newString+ "&costOfCapital="+costOfCapital.toFixed(4);
        }
        console.log("赋值后的对象字符串的值为",newString)
         */
        if (opt.validate.form()) {
            opt.operate.save(prefix + "/add", newString);
        }
    }
    function isNullOrEmpty(value) {
        return value==''||value==null||value==undefined;
    }
</script>
</@footer>
</@pageTheme>